﻿#region Using
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
#endregion Using

namespace LloydGame
{
    public class ColorAnimation
    {
        int m_state = 0;
        Vector3 m_color = Vector3.Zero;

        public Vector3 color{ get { return m_color; } }

        public ColorAnimation()
        {
        }

        public void update(GameTime p_gameTime)
        {
            float secs = p_gameTime.ElapsedRealTime.Milliseconds / 1000.0f;

            switch(m_state)
            {
                case 0:
                    m_color.Z += secs;

                    if(m_color.Z > 1.0f)
                    {
                        m_color.Z = 1.0f;
                        m_state++;
                    }

                    break;
                case 1:
                    m_color.Y += secs;
                    m_color.Z -= secs;

                    if(m_color.Y > 1.0f || m_color.Z < 0.0f)
                    {
                        m_color.Y = 1.0f;
                        m_color.Z = 0.0f;
                        m_state++;
                    }

                    break;
                case 2:
                    m_color.Z += secs;

                    if(m_color.Z > 1.0f)
                    {
                        m_color.Z = 1.0f;
                        m_state++;
                    }

                    break;
                case 3:
                    m_color.X += secs;
                    m_color.Y -= secs;
                    m_color.Z -= secs;

                    if(m_color.X > 1.0f || m_color.Y < 0.0f || m_color.Z < 0.0f)
                    {
                        m_color.X = 1.0f;
                        m_color.Y = 0.0f;
                        m_color.Z = 0.0f;
                        m_state++;
                    }

                    break;
                case 4:
                    m_color.Z += secs;

                    if(m_color.Z > 1.0f)
                    {
                        m_color.Z = 1.0f;
                        m_state++;
                    }

                    break;
                case 5:
                    m_color.Y += secs;
                    m_color.Z -= secs;

                    if(m_color.Y > 1.0f || m_color.Z < 0.0f)
                    {
                        m_color.Y = 1.0f;
                        m_color.Z = 0.0f;
                        m_state++;
                    }

                    break;
                case 6:
                    m_color.Z += secs;

                    if(m_color.Z > 1.0f)
                    {
                        m_color.Z = 1.0f;
                        m_state++;
                    }

                    break;
                case 7:
                    m_color.X -= secs;
                    m_color.Y -= secs;
                    m_color.Z -= secs;

                    if(m_color.X < 0.0f || m_color.Y < 0.0f || m_color.Z < 0.0f)
                    {
                        m_color.X = 0.0f;
                        m_color.Y = 0.0f;
                        m_color.Z = 0.0f;
                        m_state = 0;
                    }

                    break;
            }
        }
    }
}
